-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In debug, avoid force casting if an Autoload object is freed. #92608
In debug, avoid force casting if an Autoload object is freed. #92608
Conversation
modules/gdscript/gdscript_editor.cpp
Outdated
@@ -403,6 +403,11 @@ void GDScriptLanguage::debug_get_globals(List<String> *p_globals, List<Variant> | |||
|
|||
const Variant &var = gl_array[E.value]; | |||
if (Object *obj = var) { | |||
bool freed = false; | |||
var.get_validated_object_with_check(freed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can create another method in Variant to just check the validity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed as you'd always just be fetching the object, and not needed for this case see below
modules/gdscript/gdscript_editor.cpp
Outdated
@@ -403,6 +403,11 @@ void GDScriptLanguage::debug_get_globals(List<String> *p_globals, List<Variant> | |||
|
|||
const Variant &var = gl_array[E.value]; | |||
if (Object *obj = var) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (Object *obj = var) { | |
bool freed = false; | |
if (Object *obj = var.get_validated_object_with_check(freed)) { |
Instead, no need to complicate things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
cleanup check freed
36fdecb
to
0e4d0a2
Compare
@AThousandShips friendly ping, I have updated the code per your request, PTAL :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to squash the commits and write a proper commit message, but the change itself looks good to me.
I just realized there is a previous PR doing the same thing: #89274 |
Superseded by #89274. Thanks for the contribution! |
When checking an autoload object, they are force casted, which might result a crash if the object is freed.
This PR adds an additional check to prevent the force casting.
Fixes #92607